﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

#if !SILVERLIGHT
namespace UIT.WPF.Renderers
#else

namespace UIT.Silverlight.Renderers
#endif
{
#if !SILVERLIGHT
    class TextBoxRenderer :
        WpfRenderer<Controls.Input.TextBox, TextBox>
#else
    public class TextBoxRenderer :
        SlRenderer<Controls.Input.TextBox, TextBox>
#endif
    {
        public override void Render(Controls.Input.TextBox control)
        {
            Result = new TextBox();
            Result.DataContext = control;
            Result.SetBinding(TextBox.TextProperty, new System.Windows.Data.Binding("Text") { UpdateSourceTrigger = System.Windows.Data.UpdateSourceTrigger.Explicit });
            Result.TextChanged += new TextChangedEventHandler(Result_TextChanged);
        }

        void Result_TextChanged(object sender, TextChangedEventArgs e)
        {
            ((TextBox)sender).GetBindingExpression(TextBox.TextProperty).UpdateSource();
        }
    }
}
